<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
	<form class="form-horizontal m" id="form-user-add">
		<input name="deptId"  type="hidden" id="treeId"/>

		<div class="form-group">
			<label class="col-sm-3 control-label">提现币种：</label>
			<div class="col-sm-2">
				<select id="thisTokinType" name="thisTokinType" class="form-control m-b">
					<option th:each="tokin : ${allCurrencyList}" th:text="${tokin.fullName}" th:value="${tokin.id}"></option>
				</select>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-3 control-label">提现数量：</label>
			<div class="col-sm-2">
				<input  name="tokinOutNum" id="tokinOutNum" class="form-control" type="text">
			</div>
			<div class="col-sm-2" style="height:34px;line-height:34px;color: #0d8ddb">
				<a style="color: #676a6c">可提余额: </a><a style="color: #676a6c" th:text="${usdtBalance}"></a>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-3 control-label ">USDT提现：</label>
			<div class="col-sm-5" style="background: #e7eaec; padding-top:12px;">
				<div class="form-group">
					<label class="col-sm-3 control-label">钱包地址：</label>
					<div class="col-sm-5">
						<input class="form-control" type="text" name="receiveAdress" id="receiveAdress" >
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">备注：</label>
					<div class="col-sm-5">
						<input class="form-control" type="text" name="receiveRemark" id="receiveRemark">
					</div>
				</div>
			</div>
		</div>

		<div class="form-group"></div>
		<div class="form-group">
			<label class="col-sm-3 control-label"></label>
			<div class="col-sm-5">
				<div class="btn-group-sm hidden-xs" id="toolbar" role="group">
					<a class="btn btn-success col-sm-4" onclick="submitHandler()" >
						<i class="fa fa-plus"></i> 提交
					</a>
				</div>
			</div>
		</div>
	</form>
</div>
<div th:include="include::footer"></div>
<script th:src="@{/ajax/libs/select/select2.js}"></script>
<script>
    $("#form-user-add").validate({
        rules:{
            tokinOutNum:{
                required:true,
                number : "请输入数字！",
                range:[10,[[${usdtBalance}]]],
                minlength: 1,
                maxlength: 10
            },
            receiveAdress:{
                required:true,
                minlength: 2,
                maxlength: 100
            },
            receiveRemark:{
                required:false,
                maxlength: 20
            },
        },
        messages: {
            tokinOutNum: {
                required: "提币数量必须填写",
                range: "提币数量必须介于10-[[${usdtBalance}]]之间"
            }
        }
    });

    function submitHandler() {
        if ($.validate.form()) {
            tixian();
        }
    }

    function tixian() {
        var tokinOutNum = $("input[name='tokinOutNum']").val();
        var receiveAdress = $("input[name='receiveAdress']").val();
        var receiveRemark = $("input[name='receiveRemark']").val();
        $.ajax({
            cache : true,
            type : "POST",
            url : ctx + "agent/tixian",
            data : {
                "tokinOutNum": tokinOutNum,
                "receiveAdress": receiveAdress,
                "receiveRemark": receiveRemark,
            },
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                if(data.code != 0){
                    $.modal.alertError("" + data.msg);
				}else{
                    $.modal.alertSuccess("" + data.msg);
				}
                // $.operate.successCallback(data);
            }
        });
    }
</script>
</body>
</html>
